home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_placegroups.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  2KB  |  115 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. VOID
  17. LTP_PlaceGroups(LayoutHandle *handle,ObjectNode *group,LONG left,LONG top)
  18. {
  19.     if(!handle->Failed)
  20.     {
  21.         ObjectNode    *node;
  22.         LONG         plusLeft,
  23.                      plusTop,
  24.                      lastSpace;
  25.  
  26.         if(group->Label || group->Special.Group.Frame || group->Special.Group.FrameType == FRAMETYPE_Label)
  27.         {
  28.             plusLeft = 4 + handle->GlyphWidth + handle->InterWidth + group->Special.Group.ExtraLeft;
  29.  
  30.             if(group->Label)
  31.                 plusTop = handle->GlyphHeight + handle->InterHeight + group->Special.Group.ExtraTop;
  32.             else
  33.                 plusTop = 2 + handle->InterHeight + group->Special.Group.ExtraTop;
  34.         }
  35.         else
  36.         {
  37.             plusLeft    = group->Special.Group.ExtraLeft;
  38.             plusTop     = group->Special.Group.ExtraTop;
  39.         }
  40.  
  41.         if(group->ExtraSpace)
  42.         {
  43.             if(group->Special.Group.ParentGroup->Special.Group.Horizontal)
  44.                 left += handle->InterWidth;
  45.             else
  46.                 top += handle->InterHeight;
  47.         }
  48.  
  49.         group->Left    = left;
  50.         group->Top    = top;
  51.  
  52.         left    += plusLeft;
  53.         top        += plusTop;
  54.  
  55.         if(group->Special.Group.Horizontal)
  56.         {
  57.             lastSpace = left;
  58.  
  59.             SCANGROUP(group,node)
  60.             {
  61.                 if(LIKE_STRING_KIND(node) && node->Special.String.LinkID != -1)
  62.                     handle->Count++;
  63.                 else
  64.                 {
  65.                     if(node->Type == GROUP_KIND)
  66.                         LTP_PlaceGroups(handle,node,lastSpace,top);
  67.                     else
  68.                     {
  69.                         node->Left    += left;
  70.                         node->Top    += top;
  71.  
  72.                         handle->Count++;
  73.                     }
  74.  
  75.                     if(!group->Special.Group.Paging)
  76.                     {
  77.                         lastSpace = node->Left + node->Width + handle->InterWidth;
  78.  
  79.                         if(node->Type == MX_KIND)
  80.                         {
  81.                             if((node->LabelPlace == PLACETEXT_RIGHT) || (node->LabelPlace == PLACETEXT_LEFT))
  82.                                 lastSpace += INTERWIDTH + node->Special.Radio.LabelWidth;
  83.                         }
  84.                     }
  85.                 }
  86.             }
  87.         }
  88.         else
  89.         {
  90.             lastSpace = top;
  91.  
  92.             SCANGROUP(group,node)
  93.             {
  94.                 if(LIKE_STRING_KIND(node) && node->Special.String.LinkID != -1)
  95.                     handle->Count++;
  96.                 else
  97.                 {
  98.                     if(node->Type == GROUP_KIND)
  99.                         LTP_PlaceGroups(handle,node,left,lastSpace);
  100.                     else
  101.                     {
  102.                         node->Left    += left;
  103.                         node->Top    += top;
  104.  
  105.                         handle->Count++;
  106.                     }
  107.  
  108.                     if(!group->Special.Group.Paging)
  109.                         lastSpace = node->Top + node->Height + handle->InterHeight;
  110.                 }
  111.             }
  112.         }
  113.     }
  114. }
  115.